package com.ruoyi.rsikManage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.rsikManage.domain.TMonitoringEquipment;
import com.ruoyi.rsikManage.service.ITMonitoringEquipmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 监控设备列表Controller
 *
 * @author sxygsj
 * @date 2024-06-24
 */
@RestController
@RequestMapping("/rsikManage/MonitoringEquipment")
public class TMonitoringEquipmentController extends BaseController
{
    @Autowired
    private ITMonitoringEquipmentService tMonitoringEquipmentService;

    /**
     * 查询监控设备列表列表
     */
    //@PreAuthorize("@ss.hasPermi('rsikManage:MonitoringEquipment:list')")
    @GetMapping("/list")
    public TableDataInfo list(TMonitoringEquipment tMonitoringEquipment)
    {
        startPage();
        List<TMonitoringEquipment> list = tMonitoringEquipmentService.selectTMonitoringEquipmentList(tMonitoringEquipment);
        return getDataTable(list);
    }

    /**
     * 导出监控设备列表列表
     */
    //@PreAuthorize("@ss.hasPermi('rsikManage:MonitoringEquipment:export')")
    @Log(title = "监控设备列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TMonitoringEquipment tMonitoringEquipment)
    {
        List<TMonitoringEquipment> list = tMonitoringEquipmentService.selectTMonitoringEquipmentList(tMonitoringEquipment);
        ExcelUtil<TMonitoringEquipment> util = new ExcelUtil<TMonitoringEquipment>(TMonitoringEquipment.class);
        util.exportExcel(response, list, "监控设备列表数据");
    }

    /**
     * 获取监控设备列表详细信息
     */
    //@PreAuthorize("@ss.hasPermi('rsikManage:MonitoringEquipment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tMonitoringEquipmentService.selectTMonitoringEquipmentById(id));
    }

    /**
     * 新增监控设备列表
     */
    //@PreAuthorize("@ss.hasPermi('rsikManage:MonitoringEquipment:add')")
    @Log(title = "监控设备列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TMonitoringEquipment tMonitoringEquipment)
    {
        return toAjax(tMonitoringEquipmentService.insertTMonitoringEquipment(tMonitoringEquipment));
    }

    /**
     * 修改监控设备列表
     */
    //@PreAuthorize("@ss.hasPermi('rsikManage:MonitoringEquipment:edit')")
    @Log(title = "监控设备列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TMonitoringEquipment tMonitoringEquipment)
    {
        return toAjax(tMonitoringEquipmentService.updateTMonitoringEquipment(tMonitoringEquipment));
    }

    /**
     * 删除监控设备列表
     */
    //@PreAuthorize("@ss.hasPermi('rsikManage:MonitoringEquipment:remove')")
    @Log(title = "监控设备列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tMonitoringEquipmentService.deleteTMonitoringEquipmentByIds(ids));
    }
}
